<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.w3.org/1999/xhtml">

<head>
    <th:block th:include="common/common_head :: commonHeader('消息通知')"/>
</head>

<body class="gray-bg">

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="tabs-container">
                <ul class="nav nav-tabs">
                    <li class="active"><a data-toggle="tab" href="#tab-1" class="grid_tab" aria-expanded="true" onclick="refreshNotice()">业务提醒</a>
                    </li>
                    <li class=""><a data-toggle="tab" href="#tab-2" class="grid_tab" aria-expanded="false" onclick="refreshRecord()">公司公告</a>
                    </li>
                </ul>
                <div class="tab-content">
                    <div id="tab-1" class="tab-pane active">
                        <div class="panel-body jqgrid_box">
                            <form id="msgRecordForm" th:action="@{/msg/message/list}" class="form-inline"></form>
                            <table id="msgRecord" class="table_list">
                            </table>
                            <div id="msgRecordPager"></div>
                        </div>
                    </div>
                    <div id="tab-2" class="tab-pane">
                        <div class="panel-body jqgrid_box">
                            <form id="noticeRecordForm" th:action="@{/msg/publish/list}" class="form-inline"></form>
                            <table id="noticeRecord" class="table_list">
                            </table>
                            <div id="noticeRecordPager"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!--引入公共js-->
<div th:include="common/onload_js :: onloadJS"></div>
<!-- Page-Level Scripts -->
<script type="text/javascript">
    var tab_width = $("#tabs div.ui-tabs-panel:not(.ui-tabs-hide)").width();
    $('.grid_tab').on('shown.bs.tab',function(){
        $($(this).attr('href')).find('.table_list').jqGrid('setGridWidth',$($(this).attr('href')).find('.jqgrid_box').width());
    });
    var recordSearcher = Searcher.create('#noticeRecord',
        [
            {
                label: "内容摘要", name: "content", index: "content",width:100, sortable: false
            },
            {label: "时间", name: "createTime", index: "createTime", width:50, sortable: false
            }
        ],
        {
            rownumbers: false, multiselect: false,
            firstLoad:false
        }
    );
    var msgSearcher = Searcher.create('#msgRecord',
        [
            {
                label: "内容摘要", name: "content", index: "content",width:100, sortable: false,
                formatter: function (cellvalue, options, row) {
                    var result = "";
                    var name = "";

                    if (cellvalue != null && cellvalue != "") {
                        var order = "'"+row.orderNo+"'";
                        name += "<a onclick="+"showOrder("+order+")"+">" + cellvalue + "</a>";
                        console.log(name);
                    }
                    result += name;
                    return result;
                }
            },
            {label: "时间", name: "createTime", index: "createTime", width:50, sortable: false
            }

        ],
        {
            rownumbers: false, multiselect: false,
            firstLoad:false
        }
    );
    $(function () {
        msgSearcher.query($('#msgRecordForm').getGridParam('page'));
    });

    function refreshRecord() {
        recordSearcher.query($('#noticeRecordForm').getGridParam('page'));
    }

    function refreshNotice(){
        msgSearcher.query($('#msgRecordForm').getGridParam('page'));
    }

    function showOrder(orderNo) {
        //通过orderNo查找 ID
        Page.ajaxPOST(ctxPath + "/msg/search/order/"+orderNo,"", function (res) {
            orderId = res.orderId;
            var index = Dialog.openUrl("订单详细信息", ctxPath + '/modules/sys/msg/order_info.html/' + orderId,
                {
                    area: ['800px', '450px'],
                    maxmin: true
                }
            );
        })
    }

</script>
</body>
</html>